<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改考试')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-exam-edit" th:object="${exam}">
            <input name="examId" th:field="*{examId}" type="hidden">
            <input name="articleId" th:field="*{articleId}" type="hidden" id="articleId"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">考试名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">类别：</label>
                <div class="col-sm-8">
                    <input name="leibie" th:field="*{leibie}" class="form-control" type="text" required>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">文章：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="articleId" th:field="*{articleId}" class="form-control" type="text" required>-->
<!--                    <input name="articleName" th:field="*{article.title}" onclick="selectArticle()" id="articleName" type="text" placeholder="请选择文章" class="form-control">-->
<!--                    <span class="input-group-addon"><i class="fa fa-search"></i></span>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">文章：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="articleName" th:field="*{article.title}" onclick="selectArticle()" id="articleName" type="text" placeholder="请选择文章" class="form-control">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">文章标题：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="articleTitle" th:field="*{articleTitle}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">设定时间：</label>
                <div class="col-sm-8">
                    <input name="testTime" th:field="*{testTime}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startTime" th:value="${#dates.format(exam.startTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" th:value="${#dates.format(exam.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">启用：</label>
                <div class="col-sm-8">
                    <input name="active" th:field="*{active}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "typing/exam";
        $("#form-exam-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-exam-edit').serialize());
            }
        }

        $("input[name='startTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function selectArticle() {
        	var url = ctx + "typing/article" + "/selectArticle/";
			var options = {
				title: '选择文章',
				width: "580",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		function doSubmit(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#articleId").val(body.find('#articleId').val());
   			$("#articleName").val(body.find('#articleName').val());
   			$.modal.close(index);
		}
    </script>
</body>
</html>